package com.huang.add;

import java.util.concurrent.CountDownLatch;
/*
*
*    减法计数器  减完后  继续执行
* */
public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {
        //总数是6
        CountDownLatch latch = new CountDownLatch(6);
        for (int i = 0; i < 6; i++) {
            new Thread(()->{
                System.out.println(Thread.currentThread().getName()+"---->GO OUT");
                latch.countDown();// -1
            },String.valueOf(i).toString()).start();
        }
        latch.await(); //等待计数器归0  然后向下执行

        System.out.println("执行完成 6 个以后才会执行");

    }
}
